package com.lsmw.oss.controller;

import com.lsmw.commonutils.R;
import com.lsmw.oss.service.OSSService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/*
 *ClassName:OSSController
 *UserName:二号男嘉宾
 *CreateTime:2020/12/23 15:16
 */
@CrossOrigin
@RestController
@RequestMapping("/oss")
public class OSSController {

    private  OSSService ossService;

    @Autowired
    public OSSController(OSSService ossService){
        this.ossService = ossService;
    }

    @PostMapping
    public R uploadFile(MultipartFile file) {
        // 获取上传文件 MultipartFile
        String s = ossService.uploadFileAvatar(file);
        return R.ok().data("url",s);
    }

}
